﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true"
    CodeFile="NhapGiaDinhMuc.aspx.cs" Inherits="NhapGiaDinhMuc" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script type="text/javascript">
    function getValueHidden() {
        var s = document.getElementById('id').value;
        if (s != "") {
            document.getElementById('<%=idKhachHang.ClientID%>').value = s;
        }
    }
    function CheckOtherIsCheckedByGVID(spanChk) {
        var IsChecked = spanChk.checked;
        if (IsChecked) {
            spanChk.parentElement.parentElement.style.backgroundColor = 'lavender';

        }
        var CurrentRdbID = spanChk.id;
        var Chk = spanChk;
        Parent = document.getElementById("<%=GridView1.ClientID%>");
        var items = Parent.getElementsByTagName('input');
        for (i = 0; i < items.length; i++) {
            if (items[i].id != CurrentRdbID && items[i].type == "radio") {
                if (items[i].checked) {
                    items[i].checked = false;
                    items[i].parentElement.parentElement.style.backgroundColor = 'white';
                    items[i].parentElement.parentElement.style.color = 'black';
                }
            }
        }
    }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <div class="panel panel-success margin">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        Quản lý giá định mức vật liệu</h3>
                </div>
                <div class="panel-body">
                    <table width="100%">
                        <tr>
                            <td width="16%">
                                <span style="margin-left: 5px;">Tháng</span><br />
                                <asp:DropDownList runat="server" CssClass="form-control width98" ID="dlThang" AutoPostBack="true"
                                    OnSelectedIndexChanged="dlThang_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator3" runat="server"
                                    ControlToValidate="dlThang" ErrorMessage="Chọn tháng" Display="None" Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">Năm</span><br />
                                <asp:DropDownList runat="server" CssClass="form-control width98" ID="dlNam" AutoPostBack="true"
                                    OnSelectedIndexChanged="dlThang_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator4" runat="server"
                                    ControlToValidate="dlNam" ErrorMessage="Chọn năm" Display="None" Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">Mác</span><br />
                                <asp:DropDownList runat="server" CssClass="form-control width98" ID="dlMac" DataValueField="IDs"
                                    DataTextField="TenMacBeTong" AutoPostBack="true" OnSelectedIndexChanged="dlThang_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator1" runat="server"
                                    ControlToValidate="dlMac" ErrorMessage="Chọn mác" Display="None" Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">Loại đá</span><br />
                                <asp:DropDownList runat="server" CssClass="form-control with98" ID="dlLoaiDa" AutoPostBack="true"
                                    OnSelectedIndexChanged="dlThang_SelectedIndexChanged">
                                    <asp:ListItem Text="--Chọn loại đá--" Value=""></asp:ListItem>
                                    <asp:ListItem Text="Đá 1*2" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="Đá 2*4" Value="2"></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator2" runat="server"
                                    ControlToValidate="dlLoaiDa" ErrorMessage="Chọn loại đá" Display="None" Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">Phụ gia</span><br />
                                <asp:DropDownList runat="server" CssClass="form-control width98" ID="dlPhuGia" AutoPostBack="true"
                                    OnSelectedIndexChanged="dlThang_SelectedIndexChanged" DataValueField="IDs" DataTextField="TenLoaiVL">
                                </asp:DropDownList>
                            </td>
                            <td>
                                <span style="margin-left: 5px;">&nbsp;</span><br />
                                <asp:Button ID="btnSelect" runat="server" Text="Chọn định mức" 
                                    CssClass="btn btn-warning" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                            </td>
                            <td colspan="2" align="left">
                                <b>Đơn giá có VAT</b>
                            </td>
                            <td colspan="2" align="left">
                                <b>Đơn giá không VAT</b>
                            </td>
                        </tr>
                        <tr>
                            <td width="16%">
                                ĐM xi măng
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDMXM" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG xi măng</span>
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDGXMVAT" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGXMVAT" ValidChars="." />
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG xi măng</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDGXM" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGXM" ValidChars="." />
                            </td>
                        </tr>
                        <tr>
                            <td width="16%">
                                ĐM cát
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDMCat" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG cát</span>
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDGCatVAT" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGCatVAT" ValidChars="." />
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG cát</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDGCat" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGCat" ValidChars="." />
                            </td>
                        </tr>
                        <tr>
                            <td width="16%">
                                ĐM đá
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDMDa" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG đá</span>
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDGDaVAT" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGDaVAT" ValidChars="." />
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG đá</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDGDa" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGDa" ValidChars="." />
                            </td>
                        </tr>
                        <tr>
                            <td width="16%">
                                ĐM nước
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDMNuoc" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG nước</span>
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDGNuocVAT" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGNuocVAT" ValidChars="." />
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG nước</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDGNuoc" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGNuoc" ValidChars="." />
                            </td>
                        </tr>
                        <tr>
                            <td width="16%">
                                ĐM phụ gia
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDMPhuGia" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG phụ gia</span>
                            </td>
                            <td width="16%">
                                <asp:TextBox ID="txtDGPhuGiaVAT" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender9" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGPhuGiaVAT" ValidChars="." />
                            </td>
                            <td width="16%">
                                <span style="margin-left: 5px;">ĐG phụ gia</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDGPhuGia" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender10" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDGPhuGia" ValidChars="." />
                            </td>
                        </tr>
                        <%--<tr>
                            <td colspan="2"></td>
                            <td>
                                <span style="margin-left: 5px;"><b>Thành tiền có VAT</b></span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtThanhTienVAT" runat="server" ReadOnly="true" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td>
                                <span style="margin-left: 5px;"><b>Thành tiền không VAT</b></span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtThanhTienKhongVAT" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                        </tr>--%>
                        <tr>
                            <td colspan="6">
                                <asp:Button ID="btnSave" ValidationGroup="Them" runat="server" Style="margin-left: 5px;"
                                    Text="Lưu lại" CssClass="btn btn-primary" OnClick="btnSave_Click" />
                                <asp:Button ID="btncapnhat" runat="server" Text="Cập nhật" CssClass="btn btn-info"
                                    OnClick="btncapnhat_Click" Visible="false" />
                                <asp:Button ID="btnCancel" runat="server" Text="Nhập mới" CssClass="btn btn-warning"
                                    OnClick="btnCancel_Click" />
                            </td>
                        </tr>
                    </table>
                    <asp:ValidationSummary ID="ValidationSummary1" HeaderText="Bạn phải nhập các trường sau:"
                        ShowMessageBox="true" ValidationGroup="Them" ShowSummary="false" EnableClientScript="true"
                        runat="server" />
                </div>
            </div>
            <div style="margin: 5px;">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <b>Bảng giá định mức vật liệu</b>
                        <asp:DropDownList runat="server" CssClass="form-control width98" ID="dlThangLoc"
                            Width="140px">
                        </asp:DropDownList>
                        <asp:DropDownList runat="server" CssClass="form-control width98" ID="dlNamLoc" Width="120px">
                        </asp:DropDownList>
                        <asp:DropDownList ID="dlMacLoc" ToolTip="Chọn mác" runat="server"
                            DataValueField="IDs" Width="180px" CssClass="form-control" 
                            DataTextField="TenMacBeTong">
                        </asp:DropDownList>
                        <asp:DropDownList ID="dlLoaiDaLoc" ToolTip="Chọn loại đá" runat="server" Width="140px" CssClass="form-control" DataTextField="LoaiDa" DataValueField="IDs">
                        <asp:ListItem Text="--Chọn loại đá--" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Đá 1*2" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Đá 2*4" Value="2"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" CssClass="btn btn-warning"
                            OnClick="btnSearch_Click" />
                    </div>
                    <div style="width: 100%; margin-top: 0px;" class="wrapper">
                        
                        <asp:GridView ID="GV" runat="server" AutoGenerateColumns="false" BackColor="White"
                            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" EmptyDataText="Không có dữ liệu nào"
                            EnableModelValidation="True" ShowFooter="false" CssClass="form-control withall"
                            Width="99%" OnRowCommand="GV_RowCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="Xóa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                    ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="lbXoa" runat="server" Width="20px" Height="20px" ImageUrl="~/img/delete-24.png"
                                            OnClientClick="return confirm('Bạn chắc chắn muốn xóa ?')" CommandArgument='<%#Eval("IDs")%>'
                                            Text="Xóa" CommandName="Del" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Sửa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                    ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="lbSua" runat="server" Width="15px" Height="15px" ImageUrl="~/img/edit.ico"
                                            CommandArgument='<%#Eval("IDs")%>' Text="Sửa" CommandName="Select" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="NgayThang" ItemStyle-CssClass="padding" HeaderText="Tháng"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                <asp:BoundField DataField="TenMac" ItemStyle-CssClass="padding" HeaderText="Mác"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                <asp:BoundField DataField="LoaiDa" ItemStyle-CssClass="padding" HeaderText="Loại đá"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                <asp:BoundField DataField="TenPhuGia" ItemStyle-CssClass="padding" HeaderText="Phụ gia"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                <asp:BoundField DataField="ThanhTienVAT" ItemStyle-CssClass="padding" HeaderText="Thành tiền có VAT"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right"  />
                                <asp:BoundField DataField="ThanhTienKhongVAT" ItemStyle-CssClass="padding" HeaderText="Thành tiền không VAT"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right"  />
                            </Columns>
                            <FooterStyle BackColor="White" ForeColor="#000066" Font-Bold="True" HorizontalAlign="Left" />
                            <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" Height="30px" />
                            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                            <RowStyle BackColor="White" ForeColor="#000066" Height="30px" />
                            <SelectedRowStyle BackColor="Lavender" Font-Bold="false" />
                        </asp:GridView>
                        <div style="margin: 5px;">
                            <asp:Button ID="btnFirst" runat="server" Text="Đầu" CssClass="btn btn-primary" OnClick="btnFirst_Click" />
                            <asp:Button ID="btnPre" runat="server" Style="margin-left: 5px;" Text="Trước" CssClass="btn btn-primary"
                                OnClick="btnPre_Click" />
                            <asp:Button ID="btnNext" runat="server" Style="margin-left: 5px;" Text="Sau" CssClass="btn btn-warning"
                                OnClick="btnNext_Click" />
                        </div>
                    </div>
                </div>
                <asp:HiddenField ID="hdID" runat="server" />
                <asp:HiddenField ID="hdIDDinhMuc" runat="server" />
            </div>
            <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="Image1"
                Drag="True" BackgroundCssClass="modalBackground" PopupControlID="pnKhachHang"
                TargetControlID="btnSelect" RepositionMode="RepositionOnWindowResize">
            </cc1:ModalPopupExtender>
            <asp:Panel ID="pnKhachHang" runat="server" Style="display: none; width:90%;">
                <table>
                    <tr>
                        <td>
                            <asp:Image ID="Image1" Width="30px" Height="25px" Style="cursor: pointer;" runat="server"
                                ImageUrl="img/close.ico" ToolTip="Đóng" />
                        </td>
                    </tr>
                </table>
                <div style="background-image: url('img/content.png'); background-repeat: repeat;
                    box-shadow: 5px 5px 5px #888; border-radius: 10px; border: 1px solid #6EA1C0;
                    margin-top: -10px; width: 90%;">
                    <div style="background-color: #5B5B5B; color: White; font-weight: bold; border-radius: 5px 5px 0px 0px;
                        width: 100%; text-align: center; line-height: 26px; overflow: hidden;">
                        CHỌN BẢNG ĐỊNH MỨC VẬT LIỆU
                    </div>
                    <table width="100%" style="margin-top: -5px; padding: 5px;">
                        <tr>
                            <td>
                                <div style="width: 100%; margin-top: 5px; max-height: 250px; cursor: pointer; overflow-y: scroll;"
                                    class="wrapper">
                                    <asp:Button ID="Button1" runat="server" Text="Chọn" Width="100px" CssClass="btn btn-warning margin" OnClick="Button1_Click" />
                                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" BackColor="White"
                                        BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" EmptyDataText="Không có dữ liệu nào"
                                        EnableModelValidation="True" CssClass="form-control withall" Width="99%">
                                        <Columns>
                                        <asp:TemplateField HeaderText="Chọn" ItemStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:RadioButton ID="rdKhachHang" runat="server" Text='<%#Eval("TenPhuGia") %>' GroupName="sel" onclick="javascript:CheckOtherIsCheckedByGVID(this);" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="TenMac" ItemStyle-CssClass="padding" HeaderText="Mác"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                            <asp:BoundField DataField="TenLoaiDa" ItemStyle-CssClass="padding" HeaderText="Loại đá"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                            <asp:BoundField DataField="DMXM" ItemStyle-CssClass="padding" HeaderText="ĐM xi măng"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                            <asp:BoundField DataField="DMCat" ItemStyle-CssClass="padding" HeaderText="ĐM cát"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                            <asp:BoundField DataField="DMDa" ItemStyle-CssClass="padding" HeaderText="ĐM đá"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                            <asp:BoundField DataField="DMNuoc" ItemStyle-CssClass="padding" HeaderText="ĐM nước"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                            <asp:BoundField DataField="DMPhuGia" ItemStyle-CssClass="padding" HeaderText="ĐM phụ gia"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                            <asp:BoundField DataField="NgayBD" ItemStyle-CssClass="padding" HeaderText="Từ ngày"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                            <asp:BoundField DataField="NgayKT" ItemStyle-CssClass="padding" HeaderText="Đến ngày"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                            <asp:BoundField DataField="GhiChu" ItemStyle-CssClass="padding" HeaderText="Ghi chú"
                                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                                <asp:TemplateField Visible="false">
                                                <ItemTemplate>
                                                    <asp:Label ID="idMaKH" runat="server" Text='<%#Eval("IDs") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                        <FooterStyle BackColor="White" ForeColor="#000066" Font-Bold="True" HorizontalAlign="Left" />
                                        <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" Height="30px" />
                                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                        <RowStyle BackColor="White" ForeColor="#000066" Height="30px" />
                                        <SelectedRowStyle BackColor="Lavender" Font-Bold="false" />
                                    </asp:GridView>
                                    <asp:HiddenField ID="idKhachHang" runat="server" />
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
